<?php

function fnCountUser() {
    $results = mysql_query("select count(*) from mst_user");
    return $results;
}

function fnInsertUser($Nama,$Alamat,$Kota,$Propinsi,$Negara,$KodePos,$Telp,$Email,$LoginId,$Password,$StsAdmin) {
    $results = mysql_query("INSERT INTO `mst_user`(`nama`, `alamat`, `kota`, `propinsi`, 
    `negara`, `kodepos`, `telp`, `email`, `username`, `password`, `tgl_daftar`, `sts_admin`) 
    VALUES ('$Nama','$Alamat','$Kota','$Propinsi',
    '$Negara','$KodePos','$Telp','$Email','$LoginId','$Password',curdate(),$StsAdmin)");
    return $results;
}
    
function fnUpdateUser($Nama,$Alamat,$Kota,$Propinsi,$Negara,$KodePos,$Telp,$Email,$LoginId,$Password,$UserId) {
    $results = mysql_query("UPDATE `mst_user` 
                            SET `nama` = '$Nama', 
                                `alamat` = '$Alamat', 
                                `kota` = '$Kota', 
                                `propinsi` = '$Propinsi', 
                                `negara` = '$Negara', 
                                `kodepos` = '$KodePos', 
                                `telp` = '$Telp', 
                                `email` = '$Email', 
                                `username` = '$LoginId', 
                                `password` = '$Password'
                            WHERE `user_id` = '$UserId'");
    return $results;
}
    
function fnDeleteUser($UserId) {
    $results = mysql_query("DELETE FROM `mst_user` WHERE `user_id` = '$UserId'");
    return $results;
}

function fnLogin($LoginId, $Password) {
    $results = mysql_query("SELECT * FROM mst_user WHERE username='".$LoginId."' and password='".$Password."'");
    return $results;
}

function fnSelectUser($UserId) {
    $results = mysql_query("SELECT * FROM mst_user WHERE user_id='".$UserId."'");
    return $results;
}

function fnSelectAllUser() {
    $results = mysql_query("SELECT * FROM mst_user");
    return $results;
}

function fnCheckStsAdmin($UserId) {
    $results = mysql_query("SELECT sts_admin FROM mst_user WHERE user_id='".$UserId."'");
    return $results;
}
?>
